// MyFamily - XML based genealogy program.
// Copyright (C) 2006  Doug Swisher
// See the file COPYING.txt for license details.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

using NUnit.Framework;


namespace DataModel.Tests
{
    [TestFixture]
    public class GedExportImportCompare : ImportTests
    {

        private void DoReadExportImportCompare(string fileName)
        {
            FamilyInfo family1 = ReadGedCom(fileName, 0);

            FileInfo file = new FileInfo("foo.xml");

            SaveResults saveResults = new SaveResults(file);
            Assert.AreEqual(0, saveResults.WarningCount, "Save warning count should be zero.");

            family1.Save(file, saveResults);

            LoadResults loadResults = new LoadResults(file);

            FamilyInfo family2 = FamilyInfo.Load(file, loadResults);

            foreach (string message in loadResults.Messages)
            {
                Console.WriteLine(message);
            }

            Assert.IsNotNull(family2, "family2 should not be null");
            Assert.AreEqual(0, loadResults.WarningCount, "Load warning count should be zero.");

            Assert.AreEqual(family1, family2, "FamilyInfo should be equal");
        }


        [Test]
        public void Minimal()
        {
            DoReadExportImportCompare("Minimal.ged");
        }

        [Test]
        public void GedComSpecSample()
        {
            DoReadExportImportCompare("GedComSpecSample.ged");
        }
    }
}
